/**
 * 
 */
package com.zufangbao.earth.handler.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.demo2do.core.utils.StringUtils;
import com.zufangbao.earth.entity.particalsystem.VerifyCode;
import com.zufangbao.earth.handler.MessageHandler;
import com.zufangbao.earth.util.RandomUtils;

/**
 * @author lute
 *
 */
@Component("messageHandler")
public class MessageHandlerImpl implements MessageHandler {
	
	private static final Log logger = LogFactory.getLog(MessageHandlerImpl.class);
	
	@Value("#{remote['sms.template']}")
	private String messageTempalte;
	
	/* (non-Javadoc)
	 * @see com.zufangbao.jupiter.handler.MessageHandler#generateVerifyCode()
	 */
	public VerifyCode generateVerifyCode() {
		
		// generate random number code
		String code = RandomUtils.getRandomNumberCode(6);
		
		if(logger.isTraceEnabled()) {
			logger.trace("MessageHandlerImpl#generateVerifyCode - generating verify code: " + code);
		}
		
		return new VerifyCode(code, StringUtils.connect(messageTempalte, code));
	}

}
